package com.sc.nft.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.admin.request.*;
import com.sc.nft.admin.vo.BatchApprovalVO;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.dao.UserWalletDao;
import com.sc.nft.entity.vo.*;
import com.sc.nft.enums.SendSMSEnum;
import com.sc.nft.service.*;
import com.sc.nft.sup.PageRequest;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/filter")
@Api(tags="DAO收益排除列表")
public class FilterIncomeListController {
    private final FilterIncomeListService filterIncomeListService;


    @PostMapping(value="/getFilterList", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取过滤列表",notes="获取过滤列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<FilterListVO> getFilterList(@Valid @RequestBody DaoIdRequest request){
        return PageResult.success(filterIncomeListService.getPageFilterList(request.getDaoId(),request.getPageNo(),request.getPageSize(),request.getUserTel()));
    }

    @PostMapping(value="/addByUserTel", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "新增",notes="新增", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result addByUserTel(@Valid @RequestBody DaoUserTelRequest request){
        filterIncomeListService.addByUserTel(request.getUserTel(),request.getDaoId());
        return Result.success();
    }

    @PostMapping(value="/editByUserTel", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "编辑",notes="编辑", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result editByUserTel(@Valid @RequestBody UserTelEditRequest request){
        filterIncomeListService.editByUserTel(request.getId(),request.getUserTel(),request.getDaoId());
        return Result.success();
    }
    @PostMapping(value="/deleteById", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "删除",notes="删除", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result deleteById(@Valid @RequestBody IdRequest request){
        filterIncomeListService.deleteById(request.getId());
        return Result.success();
    }


    @PostMapping(value="/updateFilterUserPwd", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "修改市值账号密码",notes="修改市值账号密码", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result updateFilterUserPwd(@Valid @RequestBody UpdateFilterUserPwdRequest request){
        filterIncomeListService.updateFilterUserPwd(request.getUserTel(),request.getPwd());
        return Result.success();
    }

}
